package cn.wolfcode.wolf2w.search.repository;

import cn.wolfcode.wolf2w.search.api.domain.NoteEs;
import org.springframework.data.domain.Pageable;
import org.springframework.data.elasticsearch.annotations.Highlight;
import org.springframework.data.elasticsearch.annotations.HighlightField;
import org.springframework.data.elasticsearch.annotations.HighlightParameters;
import org.springframework.data.elasticsearch.core.SearchPage;
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;

public interface NoteEsRepository extends ElasticsearchRepository<NoteEs, String>{
    /**
     * 按照 目的地, 标题,, 简介 查询数据
     *
     * @param title
     * @param summary
     * @param pageable
     * @return
     */
    @Highlight(
            fields = {
                    @HighlightField(name = "title"),
                    @HighlightField(name = "summary")
            },
            parameters = @HighlightParameters(
                    preTags = "<span style='color:red'>",
                    postTags = "</span>",
                    requireFieldMatch = false,
                    fragmentSize = 800000,
                    numberOfFragments = 0
            )
    )
    SearchPage<NoteEs> queryByTitleOrSummary(String title, String summary, Pageable pageable);
}
